# -*- encoding:utf-8 -*-
'''
	moviedao.py
	======================
	@descript: 
	@copyright:chinasoft
	@author:zhangsiqi
	@date: 2021-01-27 19:27
	@version:v1.0
'''
from entity.movieentity import MovieEntity
from tool.PyMysqlUtil import PyMysqlUtil
class MovieDao:
    def __init__(self):
        self.__PyMysqlUtil = PyMysqlUtil()

    def InsertTable(self,movieEntity:MovieEntity):
        with self.__PyMysqlUtil as var_cursor:
            var_sql='INSERT INTO t_movie(t_movie.`id`,t_movie.`name`,t_movie.`pic_url`,t_movie.`release_time`,t_movie.`release_type`) VALUES (NULL,%s,%s,%s,%s)'
            var_result = var_cursor.execute(var_sql,(movieEntity.name,movieEntity.pic_url,movieEntity.release_time,movieEntity.release_type))
            pass
        return var_result

    def selecttable(self):
        var_MovieEntity_List = []
        with self.__PyMysqlUtil as var_cursor:
            var_sql='SELECT id,name,pic_url,release_type,release_time FROM t_movie'
            var_result = var_cursor.execute(var_sql)
            print('查询到的记录为：',var_result)
            var_dict_list = var_cursor.fetchall()
            for element in var_dict_list:
                var_MovieEntity = MovieEntity(**element)
                var_MovieEntity_List.append(var_MovieEntity)
                pass
            pass
        return var_MovieEntity_List

    def updatetable(self,movieEntity:MovieEntity):
        pass

    def deletetable(self,movieEntity:MovieEntity):
        pass

    pass